{% extends 'other/base.html' %}
{% load comments_tags %}


{% block title %} 搜索结果 {% endblock %}

{% block content %}

    {% if error_msg %}
        <p>{{ error_msg }}</p>
    {% endif %}


    {% for article in article_list %}
        <div class="arcicle-list">
            <header>
                <a class="label label-info"
                   href="/category/{{ article.category.bigcategory.slug }}/{{ article.category.slug }}/">{{ article.category.name }}</a>
                <h4>
                    <a href="{% url 'article:detail' article.pk %}" target="_blank"
                       title="">{{ article.title }} </a>
                </h4>
            </header>
            <div class="focus">
                <a href="{% url 'article:detail' article.pk %}" target="_blank">
                    <img class="thumb img-rounded" src="{{ article.img_link }}">
                </a>
            </div>
            <span class="note">
                                {{ article.excerpt }}
                            </span>
            <p class="auth-span">
                                <span class=" muted">
                                    <span class="iconfont">&#xe600;</span>
                                    <a href="#">{{ article.author }}</a>
                                </span>
                <span class=" muted">
                                    <span class="iconfont">&#xe61a;</span>
                                    <span>{{ article.created_time | date:"Y-m-j" }}</span>
                                </span>
                <span class=" muted">
                                    <span class="iconfont">&#xe639;</span>
                                    <span>{{ article.counter }}&#32;阅读</span>
                                </span>
                <span class=" muted">
                                    <span class="iconfont">&#xe648;</span>

                                    <span>{% get_comment_count article.id as commentscount %}{{ commentscount }}&#32;评论</span>
                                </span>

            </p>
        </div>


    {% empty %}
        <div class="no-post">暂时还没有发布的文章！</div>
    {% endfor %}



    <!--底部分页按钮显示-->
    <nav aria-label="Page navigation" style="text-align: center;">
        <div class="pagination">
            <ul class="pagination">
                {% if article_list.has_previous %}   <!--判断当前页是否有上一页-->
                    <li><a href="?page={{ page.previous_page_number }}" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a></li>
                {% endif %}

                {% for num in article_list.paginator.page_range %}  <!--循环遍历页码列表，并展示到底部-->
                    {% if pindex == article_list.number %}
                        <li><a href="">{{ num }}</a></li>
                    {% else %}
                        <li><a href="?page={{ num }}">{{ num }}</a></li>
                    {% endif %}
                {% endfor %}

                {% if article_list.has_next %}  <!--判断当前页是否有下一页-->
                    <li><a href="?page={{ page.next_page_number }}" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span></a></li>
                {% endif %}
            </ul>
        </div>
    </nav>


{% endblock %}